class Ball
# 實作內容
end
ball1 = Ball.new
puts ball1.ball_type # 印出 regular
ball2 = Ball.new("super")
puts ball2.ball_type # 印出 super
class Ball
def initialize(*name)
if name.any?
@name = name
else
@name = "regular"
end
end
def ball_type
@name
end
end
class Ball
def initialize(ball_type = "regular")
@ball_type = ball_type
end
def ball_type
@ball_type
end
end